major changes to code