The present invention relates to fuel injection in internal combustion engines and to fuel rate shaping. Especially, the invention relates to combustion engines utilizing heavy fuel oil as a fuel. In the body of the device there is arranged a chamber, in which a movable piston is arranged dividing the chamber into a first main volume and a second main volume, the volumes of which depend upon the position of the piston. Moreover, the device comprises at least one auxiliary volume, which can be united with the main volumes. The auxiliary volume can be filled with the fuel entering the device through the first main volume by utilizing the piston motion. By establishing a connection from the auxiliary volume to the second main volume a fuel flow to the second main volume is allowed.