fix request and refactoring code