added handling of errors
switched to through2 instead of through