Removed jquery and improved code