lines--further cleaned up, streamlined and commented the code.