Aerogear 782 - refactor grant method and refactoring