fix a bug and make it work