Moved uart on/off in function