logic updated with square and paranthesis