Reorganized code and added find function