removing duplicate code
consolidating code