Refactor and add sync method