Adjusted code based on PR comments