code refactoring and bugs are solved