re-organize code, API is better now!