Joshua's latest code, illustrating source of bug