fix #7 and #5

should clean up and fix #5 and #7