More refactoring, added missing try-catch