Corrected a bug and tested