basical calc function and data structures