moved sqr function