added block and trial loops and data saving