Slightly refactored the finder findResource() method to prevent few bugs and make it cleaner.