Rewrite in a better way