code "complete" but not working version of log model