(GL) Take identical line out of if-else blocks