Added simple error checking, commented code