fixed bug in diff()