fixed validity bug in normalization code