changed code for single instance of class