cleaned up code to be unix friendly