Implemeneted error checking