dynamic offset calculation and stuff