refactored to make the api more friendly