instead of this create a function and have all the logic there.