Need some help with automation!

Hard to comment because your code as it appears here has no formatting. Can you post a screenshot or something? Otherwise you can use a code block - see section 11 here.