this will help unify the conditions and keep the code concise, and is hopefully a bit more efficient.