fixed several functions