Refactor code and better http understanding