Balanced implementation(ns if not work)