Fixing an error in the code for better functionality