fixed bug with square and rectangle issue
added comments for javadocs