solved assignment

added some basic error checking as well