refactor and http output