more work towards converting code to a library