changed functions and main