Simplified code with if else option.