The present invention relates to an improved method for preparing hydrogels, such as alginate hydrogels. The hydrogels of the present invention is in particular useful for immobilization and preservation of biological material, such as cellular material, e.g. spermatozoa.