Reorder piece of code for better clarity