Fix bug on if-else statement