fixed panning function