refactory - now to form the API.