Getting -1 where expected, but throws an error...