removed while loop and use if only