Fixing bugs in program3