Removed unnecessary while loop