applied patch as per vitalys request