moved logic from struct to helper func