Some helper refactoring