Simplified the main() function by removing the redundant parition code