more refactoring
not working at all yet