Got rid of some repeating code.