proper handle of promises
ok, but sometimes the first run would crash.
crash bug fixed