Moving code around to make app more fluid