Created the master function