add return statement and fix control flow