Refined functionality and removed jquery dependency