removing duplicate code into a function