add checks and status functions, also exit on non-zero on errors