Cleaned up some code on main php file