some refactoring and function for finding similar pics