add error
fix lifetime issue
perf improvements