simplified, removed global dependencies and made configurable