Fixed code duplication and added @property instead of plain function