Move code around for clarity