Merged Daniel and Jake code