fixed up code. need to make sure it works