Edited code in response to errors

fixed a couple of bugs.