3. refactoring, the use sync function and remove unused deferred function