Code refactoring to incorporate Request object