removed all "local" definitions to avoid errors with ksh