Copied kelvin's code. Made new repository for logistic reasons.