improved javascript and added media query