Code to make a block with the layer as its name.

Hi All, I thought I'd just share this code. I've got over a hundred objects to turn into blocks. I'm organising them by layer so I made this code. I thought I'd post it in case someone finds it useful. Note, you have to keep the drawing open until you've finished or you will get a block name clash because the name number step integer variable will reset to 1.
Here it is
(defun c:bb ( / zz aa bb cc ss pp) (setq zz (entsel) ss nil aa (car zz) bb (entget aa) cc (cdr (assoc 8 bb)) ss (ssadd (cdr (assoc -1 bb))) pp (getpoint "\n Select insertion point") ) (print "ss =") (print ss) (if blocknamecounter (setq blocknamecounter (1+ blocknamecounter)) (setq blocknamecounter 1) ) (setq blockname (strcat cc ( itoa blocknamecounter))) (command "layer" "s" cc "") (command "block" blockname pp ss "") (command "insert" blockname pp "1.0" "" "" ) )