added sprintf for errors