worked, but it has some bugs