cleaned up javascript