Got rid of duplicate code.