analytical function now works