Added some validation and changed design