refactored more guard conditions