fixed minor bugs. Need to test more