added setup method.

a bit of async and refactoring