add datalogger, clean up code