move style code to top. add missing braces