I factorise my code a little bit