added converting functino & optimization