added -dir functionality