code works; fixed bugs