Fixing bug in toRems