added typechecking