changed the javascript for margins to stop flickering