refactor authorization code and add group template