working to add support for if/then, which means type declarations
need to move to the top.
moved declarations out