rprog004-pa2 code working, yet not in a perfect way, needs serious fixing