Working SelectMaxTemp subprogram