implemented most of the feedback provided by @ocramius