fixed implementation of mapBuffer