some comments after tracing through the code