refactored isEven in solution2