Fix invalid index exception
Moving login validation into activity