created method to cache variables of constructor