Moved logic into own method