Added some if the logic