added functions for calculating misc things