fixed some bugs in the new functions so that they run.