Added bunch of logic