moved return statement to proper scope