fixed some logic issues with horizonta layout