bug with "res" fixed