this is the prog2 updated code. needs testing.