fix bug; incorporate Nate's feedback