altered mystery section and cleaned up code