Simplify code by using append