refactor to get closer to nice API