fixed errors that were thrown when using '-d' (optional directory) option