Simplified logical statement and added some comments