added javascript version quickly