fixed and improved program