added some checking
added some checking