fixing subroutine offset calculation