Mkae a better implementation of PR #124