cleaning up javascript a bit