Moving logic part to utils file