I don't quite understand what is happening here.. would it be useful to extract this to a method to clarify the purpose?