modularize even and odd array stuff into functions