fixed patching, and changed line numbers for simplicity