fixing bugs in osl function