reordering of functions. avoid undeclared ones
minor styling changes. update-in instead of assoc, pos? for checking numbers