Changed code to validation