move error codes to seperate functions