Ported main functional