style: Split positioning logic into multiple functions