refacto of the HP + small improvments