Added initial error handling