Implemented square and average