moved declarations to top