Add try-catch blocks and documentation