moved logic from view file to routes.php