Fixed main function