Refactored getting html. Moved into one function