Check for actions before looping over them

This avoids nasty PHP Warnings in error logs