work on #5 and #6, fix #4