Fixed a bug with layout containing NA