This is simple logic for creating dynamic column layout like pinterest.