fixing bug with layout management