A lot happening in one line here... would be better to split this up to make it more readable.