a lot of changes to function names and removal of scope throughout