modified error checking on imputs and added some documentation.