Complete solution finally. So happy. Needs serious refactoring