Rewrite of spr function