Made JS a bit more generic