Refactor find prime factors method