cleaning up javascript