fixing logical errors.