change to more efficient implementation