added safety check