logging
remove unnecessary shuffling
reorganize rules for clarity