finally figured out ch6-exercise2