a new slightly improved version, but still very rough