Solved by ptrblck in post #13 
              
              
                The code looks alright from what I could see. 
PS: it’s generally better to post code snippets directly by wrapping them in three backticks ```.