Adjusted code for API level dependency