implemented automatic layout