moved code to application_helper