Fixed array index error and added temperature reading