more complete tested

usable version needs more work