refactor; update comments