adding the rest of the core code
solving merge conflicts