Adding waiting for transition and hopefully fix the bug