pre functions
improved type system