Consolidated error statements into one function