Copied from adriana codebase