error handling and tweet refactoring