remove unnecessary if-else and fix indent