I honestly did not understand your solution. Aren't their any 3rd party libraries which can help in this regards?