fixed code to accomodate previous changes in API.