break out offset calculation into function for later re-use.