fixed main script for Mac