finished refactoring. cleaned the code. splitted large function in 1 task functions. now it works. preliminary work on error handling policy changes.