moved write into proper block