Made the logic more clear.