cleaned up the code a bit with some help.