added typecheck to lambda