cleanup code which is causing Wsign-compare warning