Initial solution for challenge1. Still needs threading though