ex3 complete.
Need better implementation (confusing) and comments.