remove error checking duplication