Updated measuring code