adding last_sync logic