Fixed variables scope

Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>