fixed main
fixed bugs
improved performance