Main function modified