Move code to separate file