added challenge generation and some helper functions