Removed repeated code and also added ajax efforts
Resolve the conflicts