Refactored some logic statements.