cleaning up javascript and php