Cleaned up the code plus html output