fixed bugs and got working