created functions for terminal error treatment