move pool close to earlier in case error
inconsistent variable names