Removed an unnecessary while loop