changed if statement for index

now checks that user exists in the database