fixed a few bugs and changed variable names