fixed a bug where states of different basis were being added together in tocarbasis()