fixed #13, and code review issues