clean code

Removing redundant variable, redundant modifier, simplify conditions, remove cast