third version (I'm almost happy with it)