copied over all code currently in use