reworked accuracy computation; reduced code amount and prevents potential problems with input