remove duplicate code in accessing