Refactor whole thing with event and cb, avoid blocking