Some more refactoring thx to Nico