Moved I/O to evaluateQuery(query)