refactored lot of things