adding api argument for ease of testing.. and other reasons