kind of working; refactored structure