code fixed and simplified