ERROR with system

Is this your problem? Using system.* inside a custom function?