minor refactoring based on the latest comments