updated functions, errors and other stuff