commentaries.
converted common code to new function.

Signed-off-by: Tolga HOŞGÖR <fasdfasdas@gmail.com>