fixed bugs and put final touches