Correct error in logic and add comment