I get the feeling this could be placed into a separate function and tested quite easily? it would probably be a good idea, given the use of flow control & how it allows people to directly pass things into Solr