changed a function to be exportable
exit code added