check and return error if fail