refactored out conditional statements