Bug fix: avoid cast exception

* Bug fix: avoid cast exception
* Minor Change: avoid duplicate log of actions