I can enter if but not execute statements inside

Not sure what you mean with "restart buffer", but if you talk about "tempString" it is reset with each complete message (when a '\n' is received).