refactored if else statement block and handling all cases