add some bugs, lil refactor