further reducing duplicate code