fixed strange off by 1 error. part A complete