refactor to use flatsheet