fixed bugs that made some code non-functional