cleaning code & refactoring some