Improve functions that load html files
Move duplicate code from both lookup handlers into a separate function