Refactoring and implementing refresh tokens