some elegant code