Adding a findPec function, cleaning the code up