Multiple tasks from one if-statment

You can use the tone() function.
That will produce a tone on your piezzo while running other code.
Please in IDE press ctrl-t. It will line out your code. Then post again...