Small refactoring following comments from @jonasoreland