refactor assert func