based on the source code from here- http://stackoverflow.com/a/12969617