modified for matlab compiler to work with library