tidy expansion code