fixed implementation of readdir