Got rid of some duplicate code