using states instead of $location