edits based on Hongkai's code review