Workable solution, but complex