add functionality: fix #4 fix #5 fix #6