Fix synchronous call to promise returning function