You keep talking about code duplication, Maybe you should look at turning some of it into subroutines and save some space?