cleaned up javascript a bit