trying to rewrite code