replaced fprintf with std::cerr