issue #39 : move chown & chmod into functions