Added the rest of the logic