Re-arranging code to be bottom up