split auth code into separate module. working on core