fixed bugs. tested. works