replace error assertion in lua