Try again and optimize code