Please don’t post images as we cannot copy/paste the code in order to debug and the forum search also won’t be able to index your post.
You can post code snippets by wrapping them into three backticks ```, which would make debugging easier 
Make sure the code is executable (i.e. we can copy it and directly execute).