minor refactoring of code