optimize telescope related code