added square object
removed memory leaks with moving malloc to main