Split the if-else into different func()