Main function implemented