added offset var and fix to empty grid box