clean up repeated pyramid code