works for even and odd