crunched it into a single function