refactor level generation