Resolving issue with public variables not working