Some refactoring. Maybe this looks better