refactoring code for gradle integration