Cleared code according to vkostyukov comments