added typedef to clean up code a little
Major refactor