added error checking to facebook js