updated error handling in website and refactored some common code