minor fixes, add working
add working including edge cases