Deleted debugging code and changed return errors to fit protocol