refactored most things