changed code to improve efficiency using continue