cleaned up some functions to make them shorter
refactored large right into a module, tested, seems to be working
missing > in mobile.html