php code moved to controller from view