Implemented offset calculation.