correcting conditional statements and adding some echoing