Definitely not major. I just noticed it while reading the code. Did not even run the code. 

Nevertheless, double is not the appropriate data type. uint8 should be sufficient?