added shifts into arrays and rewrite