Added a little more logic