Add schemas code

why the flatMap?