Simplified some logic + some comments