fix http logic, need to refactor