Challenge 4 working + refactored for better c++ style