Added stuff for retrieving patterns (does not work yet)