Update to work as npm module