master_code the most optimum one

Finally the code was  working.  All the new code are trail and final
work. More modification required.