FORUM-797: Refactor code