second draft of averaging variant (incomplete)