Used .one() method and removed if else condition