added more logic