Minor refactoring of code