A fix like that would not pass many code review processes. There has got to be a better way. Maybe chain those calls in promise..then. It is great that it works but in terms of software solutions, I wouldn't promote it to production like that.