+1 this looks like it could be moved into a function