Fixed scoping issue on $html variable