addition of an error check