moved error handling to stderr