Refactors getOffset