allow offset to be a function