correct style and algorithm

Signed-off-by: Maxim Limonov <matemaks@ya.ru>