Added additional if logic with user authentication