Moved function into API.