Added return statements to prevent loop