performance optimisation
error_msg function