added generateUrl() method.
REFACTORING, refactor some method and logic
Merge pull request #4 from tonimunthi/develop

sync to master