Changed instance to local variables, since only local scope is needed.