fixed bugs for first run