improve error handling, refactor away #inject_placeholders