Combined the if-else block