Removed unnecessary while loop from earlier