refactor shadow generation