Improve code coverage and eliminate potential bug