added save button status
changed foreach syntax to more readable