ugly c++ implementations