refactored many things