Better program flow. Few things fixed