final versions, all working