Try to refactor getOffset