better error msgs and checks