The code is too much disorganised that its difficult to code. I suggest revamping the entire code from the base.