latest code -- working