created functions for setup and calculation