refactoring and removal of unnecessary parts