fixed bug with return of optional type