clean the code up a bit. make a function anonymous as it's only used in one place...