fixed bug for res