Added missing return statement

Fixed an issue where a function was not exiting when it should.