Fixed potential nullreference exception