first attempt and making it node and browserify safe