EDIT: Fixed errors. Code runs