Bug fixes; For function