added logic to authenticate users