Changed validation algorithm