refactor to run as a normal function, accepting folder path or component string as input