Code refactoring. Added progress bar and error report