code improvements as per review