Better error message
Factor out key reading