reducing duplicate code