moved some code to top to fix css selector priorities