Split this function. I'm getting lost at following it...