My first solution. Many errors.
Need to test and fix.