Cleaned up javascript a bit