sync algorithm and bug fix

Changes mainly in userServices.js