new version with jquery and easier code