animate function implemented