Main private functions