updated
working code with validation
updated code with firebase validation