fixed main function and head detached