changed method working with core data