added code for capturing theta