added simple fail-safe function