refactored condtionals, updated tests