Updated Direct API sample code