Add logic and fix offset.