Some improvements in getplen function