solved the async problem with a callback