Initial (innefficient) working version