cleaned up JS a bit