dont use while as it creates sub shell and exit is screwed