changed functions to be posix-compliant