with some bugs solved