Refactoring of Http code