Fixing signed/unsigned mismatch problem