refactor offset
attemped to reduce complexity