@abhaydas,
as your posts have been edited multiple time using the proper/required markdown tags (e.g. here) AND you're asked to use proper formatting, please use markdown code tags to edit your post before proceeding any further.
For starters, I'd suggest pasting your script in shellcheck.net and fix any identified issues.
P.S. I'd also suggest going through your earlier posts with suggested solutions - it might actually help you here as well.