heavily commented initial version