added more error first to some functions