Pull request to master

Please avoid using nested `if` statements. We can separate the nested `if` statement into its own method. Also, there is duplicate code in lines 78 - 79 with the built in `invalidateTimer` method. Use that method instead for readability and elminating duplicate code :)