added clean exit
updated and refactored
now ships with chmod