Modified code to track hand movement