non-concurrent implementation of cs107 assignment #4