restructuring to use sp classes better