This code is repeated from line 360