Refactor and make sync
Fixed async blocking