refactored defs a bit