cleaned code up a bit. releasing as v2 to npm