changed code with ability to analize sub-tasks