Fixed issue where weighted average would be outputted regardless of if it was valid.