replace while by do-while in constructor