code refactoring and making httprequest to onefile