Added the right code for extracting patches