Correct minor errors in logic