Move conditional statement to a method for readability