updated with functionality for running locally and adding comments for understandability