Added some more logic