Cleaned Math Functions - might need to be renamed