Updated the code according to the new approach