added some checks to getfield