updated code for folder list and fixed a few bugs