added error checks for duplicate usernames and created index for username