Initial working version with too much boilerplate