Moved code to private method