fix valid percentage calculation