Refactoring and added dynamic uri determination