Few corrections in the code and also added the validation which was pending.