Any suggestions on simplifying this script? It works nicely but doesn't look very elegant.


Well. At least I won lunch.
Good philosophy, see good in bad, I like!