an improved solution