New version using javascript