re-ordering operations to fix permissions issue