fixed a couple of bugs, still wrong