minor refactoring & minor fix