Main function works