fixed the corner cases of several functions