Improved read function