Used if-let form, def ^:private and defn- macro to improve readability