fix bugs and let it work