Common function for all states