this should definitely be moved to a reusable place. syncservice? not index controller anyway.