Edited Adda's original code. Works now with no errors.