adding primitive error checking