moved logic to separate file