Move the code around to respective functions.