refactor code and add single user OAuth