Modified heap main function