this one does work.
still plenty of error checking missing etc.