checking for bad loc