Fixed the error! Was not returning value in the else condition