modified with javi's clean code after d343