Fixing a bug with the code