Internal habits formation and optimality