Found on StackOverflow. I have added an answer to it Link.