Added safe-convert function