working version 80%