fixed issues: #16, 17, 18, 6