Edited coding to achieve validation