Removed duplicated code from InMemoryRepository