several improvements in functions, error evaluation needs work