Changed the main functon