fixing a bug in the code