clarified the logic