cleaning up authentication code