added optparse, not nearly done though