improved the javascript code. some fixes to css