conditional bean running and cleanup