Working on panning, made the function interface more general