Cant call function to initialize object variable