Modified several functions