refactored last if statement to return true/false