added dynamic handling in calculation