refactoring code

Signed-off-by: Dmitry Konurov <scotik1505@gmail.com>