reformatted and removed some warnings with greedy=true