Fixed  not declared as global. Also fixed code format :-)