Bug fixed

+ refactoring
+ unused code removed