Cleaned up code
Implemented error checking
Cleaned up HTML a little