After a quick look, I don't believe you ever check to see whether or not the grid position already has a value.