more performant implementation