refactored types and stuff