Rewrite to shorter code