fix condition for storing data