Reorganize legalActions to split out functions