added correct directory trimming into util