Added the getLastValid function for findblock cron