fixed error missing return, but reworked it based on comment