Made some changes to make it more scalable