added Professor's working solution