properly handles rounding and capping