modified to compile with g++ 4.8.1