make bufferPx accept a function