Replaced promise-based async code by callback-based