semi-final version with random secret code