Changed adapter. Optimized code