Please extract this into a named function. ( It's too big to go inline )