fixed numerical issues with beta