optimized code
It relates to issue #33.
Starting programming with @tchambil