refactored with @lucasmichot advices