improved performance by making thread wait for input instead of
querying if it's changed in a loop