pulling more code into API layer