some modification
get the code work right