changed to erlang record based, and significant refinement to api
revised api