issue #29

Issue #29 fix. This is olingern's solution (PR #34) using pure JS.
Merge pull request #53 from Lomanic/issue-29

issue #29