added some checking