added a safety check