Improve promise resolving