fixed bugs and cleaning up