Completed point 9 and 10

Remarks. The code is not optimized. First try to keep it simple and   run correctly, then optimize it!