Remove repeating lines of code