If statement refactor