fix offset, slight refactor