fix pattern matching so it is not greedy