cleaning & removing duplicate code