Greatly simplify code