Add cast to suppress -Wsign-compare warnings