fixed bugs, added main