writeResults method added