reordered function calls and vars