slight code refactoring