Added some checking code